package com.young.weixin.model.message;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.young.weixin.model.enums.EWxMessageTypeEnum;

/**
 * 语音消息
 *
 * @author wangjiyu
 * @date 2021/10/5 17:05
 */
@XStreamAlias("xml")
public class WxVoiceMessage extends WxBaseMessage {
    /**
     * 语音格式，如amr，speex等
     */
    @XStreamAlias("Format")
    private String format;
    /**
     * 媒体id
     */
    @XStreamAlias("MediaId")
    private String mediaId;
    /**
     * 语音识别结果，UTF8编码
     */
    @XStreamAlias("Recognition")
    private String recognition;

    /**
     * 构造消息对象
     *
     * @param fromUser 发送人
     * @param toUser   接收人
     * @return 消息对象
     */
    @Override
    public WxVoiceMessage build(String fromUser, String toUser) {
        WxVoiceMessage message = new WxVoiceMessage();
        message.fillWxBaseMessage(fromUser, toUser, EWxMessageTypeEnum.VOICE);
        return message;
    }

    /**
     * 构造消息对象
     *
     * @param messageMapWrapper 参数map
     * @return 消息对象
     */
    @Override
    public WxVoiceMessage convert(WxMessageMapWrapper messageMapWrapper) {
        WxVoiceMessage message = new WxVoiceMessage();
        message.fillWxBaseMessage(messageMapWrapper);
        message.setFormat(messageMapWrapper.getFormat());
        message.setMediaId(messageMapWrapper.getMediaId());
        message.setRecognition(messageMapWrapper.getRecognition());
        return message;
    }

    public WxVoiceMessage() {
        super();
    }

    public String getFormat() {
        return format;
    }

    public void setFormat(String format) {
        this.format = format;
    }

    public String getMediaId() {
        return mediaId;
    }

    public void setMediaId(String mediaId) {
        this.mediaId = mediaId;
    }

    public String getRecognition() {
        return recognition;
    }

    public void setRecognition(String recognition) {
        this.recognition = recognition;
    }
}
